<div ng-controller="ServiceIndexCtrl">
    <div class="bg-light lter b-b wrapper-md">
        <h1 class="m-n font-thin h3">
            <span class="font-bold" ng-bind="serviceTypeName"></span>
        </h1>
    </div>
    <div ng-class="isSmart?'':'wrapper-md'" class="remove-wrapper">
        <div class="panel panel-default">
            <div>
                <ul class="nav wrapper-sm" style="padding-bottom: 0">
                    <li class="active" style="display:inline-block;margin-bottom: 10px">
                        <button type="button" class="btn btn-info font-bold" ng-click="setStatus('all')"
                                ng-model="status" btn-radio="'all'"
                                style="margin-right:12px; min-width: 100px;">
                            <i class="fa fa-check text-active"></i>
                            {{'business.patcase.all'|translate}}
                            <span class="badge badge-red"
                                  style="position:absolute;top:-8px; z-index:99"
                                  ng-if="summary.countOfAll>0">{{summary.countOfAll}}</span>
                        </button>
                    </li>
                    <li class="active" style="display:inline-block;margin-bottom: 10px">
                        <button type="button" class="btn btn-info font-bold"
                                ng-model="status" btn-radio="'waitpaid'"
                                ng-click="setStatus('waitpaid')" style="margin-right:12px; min-width: 100px;">
                            <i class="fa fa-check text-active"></i>
                            {{'business.patcase.waitPaid'|translate}}
                            <span class="badge badge-red"
                                  style="position:absolute;top:-8px; z-index:99"
                                  ng-if="summary.countOfPay>0">{{summary.countOfPay}}</span>
                        </button>
                    </li>
                    <li class="active" style="display:inline-block;margin-bottom: 10px">
                        <button type="button" class="btn btn-info font-bold"
                                ng-model="status" btn-radio="'supplied'"
                                ng-click="setStatus('supplied')" style="margin-right:12px; min-width: 100px;">
                            <i class="fa fa-check text-active"></i>
                            {{'business.patcase.retbymedadmin'|translate}}
                            <span class="badge badge-red"
                                  style="position:absolute;top:-8px; z-index:99"
                                  ng-if="summary.countOfRetByMedAdmin+summary.countOfRetBySpecia>0">{{summary.countOfRetByMedAdmin+summary.countOfRetBySpecia}}</span>
                        </button>
                    </li>
                    <li class="active" style="display:inline-block;margin-bottom: 10px">
                        <button type="button" class="btn btn-info font-bold"
                                ng-model="status" btn-radio="'inprogress'"
                                ng-click="setStatus('inprogress')" style="margin-right:12px; min-width: 100px;">
                            <i class="fa fa-check text-active"></i>
                            {{'business.patcase.inprogress'|translate}}
                            <span class="badge badge-red"
                                  style="position:absolute;top:-8px; z-index:99"
                                  ng-if="summary.countOfInprogress>0">{{summary.countOfInprogress}}</span>
                        </button>
                    </li>
                    <li class="active" style="display:inline-block;margin-bottom: 10px">
                        <button type="button" class="btn btn-info font-bold"
                                ng-model="status" btn-radio="'finished'"
                                ng-click="setStatus('finished')"
                                style="margin-right:12px;min-width: 100px;">
                            <i class="fa fa-check text-active"></i>
                            {{'business.patcase.finished'|translate}}
                            <span class="badge badge-red"
                                  style="position:absolute;top:-8px; z-index:99"
                                  ng-if="summary.countOfFinished>0">{{summary.countOfFinished}}</span>
                        </button>
                    </li>
                </ul>
                <div class="wrapper-sm">
                    <div class="col-xs-8 col-sm-5 pull-left" style="margin-left:-15px;margin-right:-15px; ">
                        <input ng-model="like" class="form-control"
                               placeholder="{{ (selectLang == 'English') ? 'enter keywords' : '\u8bf7\u8f93\u5165\u5173\u952e\u5b57' }}"
                               type="text"
                               autocomplete="off">
                    </div>
                    <button type="button" class="btn btn-success pull-left font-bold"
                            ng-click="setStatus('all')" style=" margin-right:4px;">
                        <span translate="business.navtitle.search_patient"></span>
                    </button>
                    <button type="button" class="btn btn-danger font-bold pull-left service-a-style"
                            ng-if="serviceType.isAll != true"
                            ui-sref="app.process.selectPatient({ service_Id:service_Id })" translate="common.application">
                    </button>
                    <div class="btn-group" ng-if="serviceType.isAll == true">
                        <button type="button" class="btn btn-danger font-bold dropdown-toggle"
                                data-toggle="dropdown"
                                title="{{ 'common.application' | translate }}"
                                translate="common.application">
                            <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu">
                            <li class="text-center">
                                <a ui-sref="app.process.selectPatient({ service_Id:2 })">
                                    <span class="font-bold" translate="aside.nav.process.scheme">scheme</span>
                                </a>
                            </li>
                            <li class="text-center">
                                <a ui-sref="app.process.selectPatient({ service_Id:3 })">
                                            <span class="font-bold"
                                                  translate="aside.nav.process.screenage">screenage</span>
                                </a>
                            </li>
                            <li class="text-center">
                                <a ui-sref="app.process.selectPatient({ service_Id:5 })">
                                    <span class="font-bold" translate="aside.nav.process.appointment">appointment</span>
                                </a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
            <table class="table table-striped" style="width:100%" dt-disable-deep-watchers="true"
                   ui-options="dtOptions">
                <thead>
                <tr>
                    <th ng-class="isSmart?'col-xs-4':''" translate="business.servreq.id"></th>
                    <th translate="common.updated" ng-if="!isSmart"></th>
                    <th ng-class="isSmart?'col-xs-4':''" translate="common.name"></th>
                    <th translate="user.gender" ng-if="!isSmart"></th>
                    <th translate="business.servreq.serviceType" ng-if="!isSmart"></th>
                    <th translate="user.mobilephone" ng-if="!isSmart"></th>
                    <th translate="dashboard.specialist" ng-if="!isSmart"></th>
                    <th translate="business.servreq.status" ng-if="!isSmart"></th>
                    <th ng-class="isSmart?'col-xs-4':''" translate="common.operate"></th>
                </tr>
                </thead>
                <tbody>
                <tr ng-repeat="model in servReqs" class="row-sm-12">
                    <td>S-{{ model.servReq_Id }}</td>
                    <td ng-if="!isSmart">{{ moment(model.updated).format("YYYY-MM-DD HH:mm") }}</td>
                    <td>{{ model._patCase._patient._user.realName }}</td>
                    <td ng-if="!isSmart">
                            <span ng-show="model._patCase._patient._user.gender != null"
                                  translate="{{ 'user.gender.' + model._patCase._patient._user.gender}}">
                            </span>
                    </td>
                    <td ng-if="!isSmart"><span translate="{{'servicetype.servicetype_' + model.service_Type }}"></span>
                    </td>
                    <td ng-if="!isSmart" style="word-break: break-all">{{ model._patCase._patient._user.mobile_Phone
                        }}
                    </td>
                    <td ng-if="!isSmart">
                        <span style="cursor:pointer" ng-if="model._chosen_Expert"
                              ng-click="open({templateUrl: 'openUserInfoo.html'}, {{model._chosen_Expert}})">
                            {{ model._chosen_Expert.realName}}
                        </span>
                    </td>
                    <td ng-if="!isSmart">{{ (selectLang == 'English') ? model._status.enName : model._status.cnName }}
                    </td>
                    <td class="nowrap-remove">
                        <!--详情-->
                        <button type="button" class="btn btn-sm btn-info font-bold"
                                title="{{ 'common.details' | translate }}"
                                translate="common.details"
                                ng-click="open({ templateUrl: 'servreqFlow.html' }, model)">
                        </button>
                        <button type="button" class="btn btn-sm btn-warning font-bold"
                                title="{{ 'common.edit' | translate }}"
                                translate="common.edit"
                                ng-click="open({ templateUrl: 'editPatient.html' }, model._patCase.patient_Id)"
                                ng-if="model.canSetInitial">
                        </button>
                        <button type="button" class="btn btn-sm btn-success font-bold"
                                title="{{ 'business.servreq.pay' | translate }}"
                                translate="business.servreq.pay"
                                ng-if="model.canBePaid"
                                ui-sref="app.process.pay({servReq_Id:model.servReq_Id})">
                        </button>
                        <button type="button" class="btn btn-sm btn-danger font-bold"
                                title="{{ 'business.servreq.setCancelled' | translate }}"
                                translate="business.servreq.setCancelled"
                                ng-if="model.canSetCancelled"
                                ng-click="openCancelled({ templateUrl: 'servreqCancel.html' }, model)">
                        </button>
                        <button type="button" class="btn btn-sm btn-primary font-bold"
                                title="{{ 'business.patcase.send_to_assistant' | translate }}"
                                translate="business.patcase.send_to_assistant"
                                ng-click="openSetInitial({ templateUrl: 'setInitial.html', size: 'sm' }, model)"
                                ng-if="model.canSetInitial">
                        </button>
                    </td>
                </tr>
                </tbody>
            </table>

            <footer class="panel-footer">
                <div class="row">
                    <div class="col-sm-4 text-left">
                        <small class="text-muted inline m-t-sm m-b-sm"><span translate="common.showing"></span>
                            {{page.totalItems==0?0:(page.currentPage-1)*page.itemsPerPage+1}}
                            - {{(page.currentPage-1)*page.itemsPerPage+page.currentItems}}
                            <span translate="common.of"></span> {{page.totalItems}} <span
                                    translate="common.items"></span>
                        </small>
                    </div>
                    <div class="col-sm-8 text-right text-center-xs">
                        <pagination ng-model="page.currentPage" ng-change="pageChanged()"
                                    total-items="page.totalItems" items-per-page="page.itemsPerPage"
                                    max-size="page.maxSize" class="pagination-sm m-t-none m-b"
                                    boundary-links="true" rotate="false" previous-text="&lsaquo;"
                                    next-text="&rsaquo;" first-text="&laquo;" last-text="&raquo;"></pagination>
                    </div>
                </div>
            </footer>
        </div>
    </div>
</div>

<script type="text/ng-template" id="servreqCancel.html">
    <div>
        <div class="modal-header">
            <h4>
                <span translate="business.servreq.setCancelled"></span>
                <button type="button" class="close" ng-click="cancel()"><span class="icon icon-close"
                                                                              aria-hidden="true"></span></button>
            </h4>
        </div>
        <div class="modal-body">
            <div class="container purepage-servList" ng-repeat="item in items">
                <div class="row">
                    <div class="col-xs-6">
                        <span translate="business.servreq.id"></span>:&nbsp;&nbsp;
                        <span>S-{{item.servReq_Id}}</span>
                    </div>
                    <div class="col-xs-6">
                        <span translate="common.updated"></span>:&nbsp;&nbsp;
                        <span>{{ moment(item.updated).format("YYYY-MM-DD HH:mm") }}</span>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-6">
                        <span translate="user.realname"></span>:&nbsp;&nbsp;
                        <span>{{item._patCase._patient._user.realName}}</span>
                    </div>
                    <div class="col-xs-6">
                        <span translate="user.mobilephone"></span>:&nbsp;&nbsp;
                        <span>{{item._patCase._patient._user.mobile_Phone }}</span>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-6">
                        <span translate="business.servreq.service"></span>:&nbsp;&nbsp;
                        <span>{{ item._servType.service_Name}}</span>
                    </div>
                    <div class="col-xs-6">
                        <span translate="business.servreq.status"></span>:&nbsp;&nbsp;
                        <span>{{ item._status.cnName}}</span>
                    </div>
                </div>
            </div>

        </div>

        <div class="modal-footer">
            <button class="btn btn-danger" ng-click="ok()" translate="business.servreq.confirmCancelled"></button>
            <button class="btn btn-default" ng-click="cancel()" translate="common.close"></button>
        </div>
    </div>
</script>

<script type="text/ng-template" id="openUserInfoo.html">
    <div ng-include="'views/system/user_detail.html?tmp=2'"></div>
</script>

<div ng-include="'views/work/templates.html'"></div>